<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta name="robots" content="noindex,nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<META HTTP-EQUIV="pragma" CONTENT="no-cache"> 
<META HTTP-EQUIV="Cache-Control" CONTENT="no-store, must-revalidate"> 
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT"> 
<META HTTP-EQUIV="expires" CONTENT="0"> 
<link rel="stylesheet" type="text/css" href="layui/css/layui.css" />
<link rel="stylesheet" type="text/css" href="css/x.css"/>
<title>预约列表</title>
<script src="js/common.js" type="text/javascript"></script>
<script src="js/main.js" type="text/javascript"></script>
<script src="layui/layui.js" type="text/javascript"></script>
</head>
<body>
<!--当前导航-->
<?php
    require_once(dirname(__FILE__)."/../../data/config.plus.inc.php"); 
    $numPerPage=$PLUS["Other"]["numPerPage"];

    if(empty($order)) $order="id";
    $order=trim(str_replace("desc","",$order));
    $orderStr= " order by d.$order desc";
    $page = isset($page) ? intval($page) : 1;
    if($page==0) $page=1;

    $groupid = $cuserLogin->getgroupid();
    $userid =  $cuserLogin->getUserID();
    $publish = $cuserLogin->getpublish();

    if($groupid==3){
      $whereStr=" d.aid='$userid'";
      $csqlStr="select count(*) as dd from `sea_subscribe` d where d.aid='$userid'";
    }else{
      $whereStr=" ";
      $csqlStr="select count(*) as dd from `sea_subscribe` d";
    }
 
	  if (!empty($area)) $whereStr.=" and d.v_publisharea = '$area'";

    if (!empty($type)) $whereStr.=" and d.tid in (".getTypeId($type).")";
    if (!empty($keyword)) $whereStr.=" and d.title like '%".$keyword."%' or d.v_publisharea like '%".$keyword."%' or d.v_director like '%".$keyword."%' or d.user like '%".$keyword."%' or v.title like '%".$keyword."%' ";

    if(strlen($whereStr)>2) $whereStr = "where ".$whereStr;

    $whereorder = $whereStr.$orderStr;

	//计算有多少条数据
    $row = $dsql->GetOne($csqlStr);
    if(is_array($row)){
        $TotalResult = $row['dd'];
    }else{
        $TotalResult = 0;
    }

    $TotalPage = ceil($TotalResult/$numPerPage);
    if ($page>$TotalPage) $page=$TotalPage;
    $limitstart = ($page-1) * $numPerPage;
    if($limitstart<0) $limitstart=0;
    
    $sqlStr="select d.id,d.tid,d.pid,d.publish,d.title,d.vid,v.title as vt,v.stat as vs,t.tname,d.v_pic,sd.v_addtime,sd.v_enname,d.start,d.end,d.v_publisharea,d.v_director,d.user,d.file_name,d.stat,a.nickname from sea_subscribe d left join `sea_vod` v on v.id=d.vid left join `sea_type` t on t.tid=d.tid left join `sea_data` sd on sd.v_id=d.pid left join `sea_admin` a on a.id=d.aid ".$whereorder." limit $limitstart,$numPerPage";
	  $jumpurl = "&action=$action&order=$order&type=$type&area=$area&keyword=$keyword";

    // $str:原字符串，$suffix:子字符串（区分大小写）
    function endWith($str, $suffix)
    {   
        $length = strlen($suffix);
        if ($length == 0) {
            return true;
        }   
        return (substr($str, -$length) === $suffix);
    } 
?>
<div class="layui-fluid">
  <div class="r_content pd15">
    <div style="overflow-x: auto">
      <table class="layui-table" style="min-width:1170px;">
          <form action="?" method="post" >
            
			<tr><th colspan="<?php if($groupid!=3) echo "12";else echo "11"; ?>">预约管理&nbsp;&nbsp;<input  name="keyword" type="text" id="keyword" size="20">
              
              <select name="type" id="type"  >
                <option value="">全部分类</option>
                <?php makeTypeOption(0,"　",0)?>
              </select>
			  <input type="submit" name="selectBtn" value="查询或重置" class="btn"  />
              &nbsp;
              <select  onchange="self.location.href='?&order=<?php echo $order;?>&keyword=<?php echo $keyword;?>&area=<?php echo $area;  ?>&type='+this.options[this.selectedIndex].value">
                <option value="">按分类</option>
                <?php makeTypeOption(0,"　",0)?>
              </select> 

			  <select id='area' name='area' style="width:80px" onChange="self.location.href='?v_recycled=<?php echo $v_recycled ?>&v_isunion=<?php echo $v_isunion ?>&v_ismoney=<?php echo $v_ismoney ?>&v_ispsd=<?php echo $v_ispsd ?>&order=<?php echo $order;?>&type=<?php echo $type;?>&keyword=<?php echo $keyword;?>&v_state=<?php echo $v_state;?>&v_commend=<?php echo $v_commend;?>&repeat=<?php echo $repeat;?>&topic=<?php echo $topic;?>&playfrom=<?php echo $playfrom;?>&downfrom=<?php echo $downfrom;?>&empty=<?php echo $empty;?>&rlen=<?php echo $rlen;?>&jqtype=<?php echo $jqtype;  ?>&year=<?php echo $year;  ?>&yuyan=<?php echo $yuyan;  ?>&letter=<?php echo $letter;  ?>&commend=<?php echo $commend;  ?>&ver=<?php echo $ver;  ?>&area='+this.options[this.selectedIndex].value">
                <option value=''>按年级</option>
                <?php echo zzget('area');?>
              </select> 
			  </th></tr>
          </form> 
        </tr>
        <?php
if($TotalResult==0){
    if(!empty($keyword)){
    echo "<tr><td colspan='10'>关键字  <font color=red>\"".$keyword."\"</font>   没有记录</td></tr>";
    }
}else{
	if(!empty($keyword)){
?>
        <tr >
          <td colspan="10">关键字 <font color=red> <?php echo $keyword;?> </font> 的记录如下</td>
        </tr>
        <?php
	}
}
?> <tbody>
        <tr style="background-color: #F6F6F6;" align="center">
          <td width="5%" align="center">&nbsp;<a href="?order=id&page=<?php echo $page;?>&type=<?php echo $type;?>&area=<?php echo $area;?>&keyword=<?php echo $keyword;?>">ID<img src="img/minus.gif" title="按ID排序" /></a></td>
          <td width="7%">状态</td>
          <td width="15%">标题</td>
          <td width="8%">视频来源</td>
          <?php if($groupid!=3) echo "<td width='7%'>创建人</td>" ?>
          <td width="11%"><a href="?order=start&page=<?php echo $page;?>&type=<?php echo $type;?>&area=<?php echo $area;?>&keyword=<?php echo $keyword;?>">开始时间<img src="img/minus.gif" title="按开始时间排序" /></a></td>
          <td width="11%"><a href="?order=end&page=<?php echo $page;?>&type=<?php echo $type;?>&area=<?php echo $area;?>&keyword=<?php echo $keyword;?>">结束时间<img src="img/minus.gif" title="按结束排序" /></a></td>
          <td width="7%"><a href="?order=tid&page=<?php echo $page;?>&type=<?php echo $type;?>&area=<?php echo $area;?>&keyword=<?php echo $keyword;?>">分类<img src="img/minus.gif" title="按分类排序" /></a></td>             
          <td width="7%">执教</td>         
          <td width="7%">年级</td>
          <td width="6%">班级</td>                 
          <td width="9%">操作</td>
        </tr>
        <form method="post" name="vodlistform">
          <?php
$stats=array("<font color='green'>预约</font>","<font color='red'>正在录制</font>","","<font color='ORANGE'>正在转码</font>","<font color='ORANGE'>正在发布</font>","","<font color='GRAY'>录制错误</font>");
$colors=array("<font color='gray'>","<font color='green'>","<font color='red'>");



$dsql->SetQuery($sqlStr);
$dsql->Execute('vod_list');
$idgroup = "";
$statgroup = "";
while($row=$dsql->GetObject('vod_list'))
{
  $id=$row->id;
  $contentUrl=getContentLink($row->tid,$row->pid,"",date('Y-n',$row->v_addtime),$row->v_enname);

  if($row->stat！=5){
    if($idgroup!='') {
      $idgroup = $idgroup.",";
      $statgroup = $statgroup.",";
    }
    $idgroup = $idgroup . $id;
    $statgroup = $statgroup . $row->stat;
  }

  if($row->tid==0 && $row->stat==2) 
    $stats[2] = "<font color='#FF00FF'>等待分类</font>";
  else
    $stats[2] = "<font color='ORANGE'>等待转码</font>";

  if($groupid==3 && $publish !=1 ) 
    $stats[4] = "<font color='BLUE'>录制完毕</font>";
  else if($row->publish==1 && $row->stat==4) 
    $stats[4] = "<font color='ORANGE'>正在发布</font>";
  else
    $stats[4] = "<a href='admin_vod.php?action=cut&id=".$id."' title='播放视频'><font color='#FF00FF'>等待发布</font></a>";

    if($row->stat==5){
      $stats[5] = "<a href='$contentUrl' title='查看' target='_blank'><font color='BLUE'>发布完毕</font></a>";
    }

?>

          <tr align="center">
            <td><input type="checkbox" value="<?php echo $id;?>" name="e_id[]" class="checkbox" />
              <?php echo $id;?></td>
            <td id="stat<?= $id ?>"><?php echo $stats[$row->stat]; ?></td>
            <td align="left"><?php echo $row->title;?></td>
            <td>
              <?php if($row->vs >0) { ?>
              <a title="点击查看直播" href="admin_vod.php?playid=<?= $row->vid ?>"><?= $colors[$row->vs] ?><?= $row->vt ?></font></a>
              <?php } else { ?>
                <span title="无信号"><?= $colors[$row->vs] ?><?= $row->vt ?></font></span>
              <?php } ?>
            </td>
            <?php if($groupid!=3) echo "<td>$row->nickname</td>" ?>         
            <td><?php echo $row->start;?></td>
            <td><?php echo $row->end;?></td>  
            <td><?php echo $row->tname;?></td>                
            <td><?php echo $row->user;?></td>                
            <td><?php echo $row->v_publisharea;?></td>
            <td><?php echo $row->v_director;?></td>


            <td align="center" id="action<?= $id ?>">
              <?php if($row->stat==1){ ?>
                <a href="?action=edit&id=<?php echo $id ?>">编辑</a>&nbsp;&nbsp;<a href="#" onclick='ctrlRecord(<?php echo $row->vid;?>,0)' title = '点击停止录像'><font color=red>停止</font></a>
              <?php } else if($row->tid==0 && $row->stat==2){ ?>
                <a class='layui-btn layui-btn-xs layui-btn-radius layui-btn-normal' href='?action=edit&id=<?= $row->id ?>&publish=1'>点击分类</a>
              <?php } else if($row->publish==0 && $row->stat==4 &&($groupid!=3 || ($publish==1 && $groupid==3))){ ?>
                <a class='layui-btn layui-btn-xs layui-btn-radius layui-btn-normal' href='?action=edit&id=<?=$row->id ?>&publish=1'>点击发布</a>
              <?php } else if($row->stat<4 || $row->stat==6){ ?>
                <a href="?action=edit&id=<?php echo $id ?>">编辑</a>&nbsp;&nbsp;<a href="?action=del&id=<?php echo $id ?>" onClick="return confirm('确定要删除吗')">删除</a>
              <?php } else if( ($row->stat==4 || $row->stat==5) && endWith($row->file_name,".flv")){ ?>
                  <a href="admin_video.php?action=edit&id=<?php echo $row->pid;?>" >编辑</a>&nbsp;&nbsp;<a href="#"  onClick="flv2mp4(<?= $id ?>,<?php echo $row->pid;?>)" title="尝试将 <?php echo $row->file_name;?> 转码到mp4格式"><font color=red>转码</font></a>  
              <?php } else if($row->stat==4){ ?>
                <a href="?action=edit&id=<?php echo $id ?>">编辑</a>&nbsp;&nbsp;<a href="admin_vod.php?action=cut&id=<?php echo $id ?>" title="对视频进行播放与裁剪操作"><font color=green>播放</font></a>
              <?php } else { ?>
                <a href="admin_video.php?action=edit&id=<?php echo $row->pid;?>" >编辑</a>&nbsp;&nbsp;<a href="admin_vod.php?action=cut&id=<?php echo $id ?>" title="对视频进行播放与裁剪操作"><font color=green>播放</font></a>
              <?php } ?>
              </td>
          </tr>
  <?php }?>
          <tr>
            <td colspan="12"><label>全选&nbsp;&nbsp;<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(this.checked,'input','e_id[]')" /></label>
              &nbsp;&nbsp;<label>反选&nbsp;&nbsp;<input type="checkbox" name="chkothers" id="chkothers" class="checkbox" onclick="checkOthers('input','e_id[]')" /></label>
              &nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="批量删除" onclick="if(confirm('确定要删除吗')){vodlistform.action='?action=delall';}else{return false}" class="rb1"  />
			</td>
          </tr>
        </form>	
		</tbody>
      </table>
	  <div id="new_pages" class="layui-fluid">
	  </div>
      <?php if($idgroup!="") echo "<div style='display:none'><div id='id_group'>$idgroup</div><div id='stat_group'>$statgroup</div>"; ?>
    </div>
   </div>
</div>
</body>

<script type="text/JavaScript">
	<?php if($idgroup!=""): ?>
    setInterval(getLiveStat,1000,'id_group','stat_group');
	<?php endif; ?>	
	
	layui.use(['laypage', 'layer'], function(){
	  var laypage = layui.laypage
	  ,layer = layui.layer;
	  laypage.render({
	      elem: 'new_pages'
	      ,count: <?php echo $TotalResult;?>
		  ,limit: <?php echo $numPerPage;?>
		  ,curr:<?php echo $page;?>
	      ,layout: ['count', 'prev', 'page', 'next', 'skip']
	      ,jump: function(obj,first){
			  if(!first){
				location.href = '?page='+ obj.curr +'&action=<?php echo $action ?>&order=<?php echo $order;?>&type=<?php echo $type;?>&keyword=<?php echo $keyword;?>&area=<?php echo $area; ?>';
			}
	      }
	    });
	  });
</script>
</html>
